﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;

namespace SportsStore.Domain.Concrete
{
    public class EFDocumentRepository:IDocumentRepository
    {
        private KeLianEntities context = new KeLianEntities();

        public IQueryable<Document> Documents { get { return context.Documents; } }

        public void AddDocument(Document document)
        {
            try
            {
                if (document.Id == 0)
                {
                    context.Documents.AddObject(document);
                }
                context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }

            
        }

        public void DeleteDocument(Document document)
        {
            context.Documents.DeleteObject(document);
            context.SaveChanges();
        }
    }
}
